#include <stdio.h>
#include "aMaze-ing.h"
#include <stdlib.h>
#include "example.h"

Card** setup()
{
	Card **Board=(Card**)malloc (HEIGHT*sizeof(Card*));
	Card *Content=(Card*)malloc(HEIGHT*WIDTH*sizeof(Card));
	int i;
	for (i=0; i< HEIGHT; i++) Board[i]=Content+i*WIDTH;
	Board[0][0]=(Card) {0,1,0,1,owl,1,0,0,0};
	Board[0][1]=(Card) {0,0,1,0,none,0,1,0,0};
	Board[1][0]=(Card) {1,0,0,0,none,0,0,0,0  };
	Board[1][1]=(Card) {0,1,0,1,key,0,0,0,1};
	return Board;
}

void dispCluster(Cluster c)
{
	int i;
	printf("Card count: %i\n", c.card_count);
 	printf("treasure_count: %i\n", c.treasure_count );
 	for (i=0; i< c.treasure_count; i++) printf("treasure: %d\n", (int)c.treasure_contains[i] );
 	printf("contains_me %i\n", c.contains_me);
  	printf("contains_second %i\n", c.contains_second);
  	printf("contains_third %i\n", c.contains_third);
  	printf("contains_fourth %i\n", c.contains_fourth);
}

void dispDraw(Draw m)
{
	int i;
	printf("Can win: %i\n", m.winning );
	printf("Should go %i,%i\n",m.closest_x, m.closest_y );
	printf("Treasure is %i,%i\n", m.goal_x, m.goal_y);
	//printf("IsWorth: %i\n", m.value);
	printf("Clusters found: %i\n", m.cluster_count);
	for (i=0; i< m.cluster_count; i++)
	{
		printf("\nCluster No. %i\n", i+1);
		dispCluster(m.cluster_contains[i]);
	}
	
}

void dispBoard(Card** Board)
{
	int i,j;
	for(i=0;i<HEIGHT;i++)
	{
		for (j=0; j<WIDTH;j++)
		{
			printf("%i",Board[i][j].treasure);
		}
		printf("\n");
	}
}

int main(int argc, char const *argv[])
{
	Card ** Board=setup();
	Card crd={1,0,1,0,chest,0,0,1,0};
	Draw Draw = getDraw(Board, &crd, -1, -1, -1, owl);
	int i;
	/*for (i=0; i<4*2*2; i++)
	{
		printf("\nDraw No: %i\n",i);*/
		dispDraw(Draw);
	//}
	return 0;
}